home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / gcc / ixemul-4.lha / ixemul-41.4 / include / fcntl.h < prev    next >
C/C++ Source or Header  |  1995-10-02  |  7KB  |  191 lines

  1. /*-
  2.  * Copyright (c) 1983, 1990 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)fcntl.h    5.14 (Berkeley) 7/1/91
  34.  */
  35.  
  36. #ifndef _FCNTL_H_
  37. #define    _FCNTL_H_
  38.  
  39. /*
  40.  * This file includes the definitions for open and fcntl
  41.  * described by POSIX for <fcntl.h>; it also includes
  42.  * related kernel definitions.
  43.  */
  44.  
  45. #ifndef KERNEL
  46. #include <sys/types.h>
  47. #endif
  48.  
  49. /*
  50.  * File status flags: these are used by open(2), fcntl(2).
  51.  * They are also used (indirectly) in the kernel file structure f_flags,
  52.  * which is a superset of the open/fcntl flags.  Open flags and f_flags
  53.  * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
  54.  * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
  55.  */
  56. /* open-only flags */
  57. #define    O_RDONLY    0x0000        /* open for reading only */
  58. #define    O_WRONLY    0x0001        /* open for writing only */
  59. #define    O_RDWR        0x0002        /* open for reading and writing */
  60. #define    O_ACCMODE    0x0003        /* mask for above modes */
  61.  
  62. #ifdef KERNEL
  63. /*
  64.  * Kernel encoding of open mode; separate read and write bits
  65.  * that are independently testable: 1 greater than the above.
  66.  */
  67. #define    FREAD        0x0001
  68. #define    FWRITE        0x0002
  69. #endif
  70. #define    O_NONBLOCK    0x0004        /* no delay */
  71. #define    O_APPEND    0x0100        /* set append mode */
  72. #ifndef _POSIX_SOURCE
  73. #define    O_SHLOCK    0x0        /* open with shared file lock */
  74. #define    O_EXLOCK    0x0        /* open with exclusive file lock */
  75. #define    O_ASYNC        0x0040        /* signal pgrp when data ready */
  76. #define    O_FSYNC        0x2000        /* synchronous writes */
  77. #endif
  78. #define    O_CREAT        0x0200        /* create if nonexistant */
  79. #define    O_TRUNC        0x0400        /* truncate to zero length */
  80. #define    O_EXCL        0x0800        /* error if already exists */
  81. #ifdef KERNEL
  82. #define FEXTOPEN    0x0010        /* don't close with DOS Close command */
  83. #define FTTYRAW        0x0020        /* tty in RAW mode */
  84. #define FUNLINK        0x0080        /* unlink file when closed */
  85. #define    FMARK        0x0        /* mark during gc() */
  86. #define    FDEFER        0x0        /* defer for next gc pass */
  87. #define    FHASLOCK    0x0        /* descriptor holds advisory lock */
  88. #endif
  89.  
  90. /* defined by POSIX 1003.1; BSD default, so no bit required */
  91. #define    O_NOCTTY    0        /* don't assign controlling terminal */
  92.  
  93. #ifdef KERNEL
  94. #define    FOPEN        (-1)
  95. /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
  96. #define    FFLAGS(oflags)    ((oflags) + 1)
  97. #define    OFLAGS(fflags)    ((fflags) - 1)
  98.  
  99. /* bits to save after open */
  100. #define    FMASK        (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  101. /* bits settable by fcntl(F_SETFL, ...) */
  102. #define    FCNTLFLAGS    (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FEXTOPEN)
  103. #endif
  104.  
  105. /*
  106.  * The O_* flags used to have only F* names, which were used in the kernel
  107.  * and by fcntl.  We retain the F* names for the kernel f_flags field
  108.  * and for backward compatibility for fcntl.
  109.  */
  110. #ifndef _POSIX_SOURCE
  111. #define    FAPPEND        O_APPEND    /* kernel/compat */
  112. #define    FASYNC        O_ASYNC        /* kernel/compat */
  113. #define    FFSYNC        O_FSYNC        /* kernel */
  114. #define    FNONBLOCK    O_NONBLOCK    /* kernel */
  115. #define    FNDELAY        O_NONBLOCK    /* compat */
  116. #define FNBIO        O_NONBLOCK    /* compat */
  117. #define    O_NDELAY    O_NONBLOCK    /* compat */
  118. #endif
  119.  
  120. /*
  121.  * Constants used for fcntl(2)
  122.  */
  123.  
  124. /* command values */
  125. #define    F_DUPFD        0        /* duplicate file descriptor */
  126. #define    F_GETFD        1        /* get file descriptor flags */
  127. #define    F_SETFD        2        /* set file descriptor flags */
  128. #define    F_GETFL        3        /* get file status flags */
  129. #define    F_SETFL        4        /* set file status flags */
  130. #ifndef _POSIX_SOURCE
  131. #define    F_GETOWN    5        /* get SIGIO/SIGURG proc/pgrp */
  132. #define F_SETOWN    6        /* set SIGIO/SIGURG proc/pgrp */
  133. #endif
  134. #if 0                    /* Currently unimplemented */
  135. #define    F_GETLK        7        /* get record locking information */
  136. #define    F_SETLK        8        /* set record locking information */
  137. #define    F_SETLKW    9        /* F_SETLK; wait if blocked */
  138. #endif
  139.  
  140. /* file descriptor flags (F_GETFD, F_SETFD) */
  141. #define    FD_CLOEXEC    1        /* close-on-exec flag */
  142.  
  143. /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
  144. #if 0                    /* Currently unimplemented */
  145. #define    F_RDLCK        1        /* shared or read lock */
  146. #define    F_UNLCK        2        /* unlock */
  147. #define    F_WRLCK        3        /* exclusive or write lock */
  148. #endif
  149. #ifdef KERNEL
  150. #define    F_WAIT        0x010        /* Wait until lock is granted */
  151. #define    F_FLOCK        0x020         /* Use flock(2) semantics for lock */
  152. #define    F_POSIX        0x040         /* Use POSIX semantics for lock */
  153. #endif
  154.  
  155. /*
  156.  * Advisory file segment locking data type -
  157.  * information passed to system by user
  158.  */
  159. struct flock {
  160.     short    l_type;        /* lock type: read/write, etc. */
  161.     short    l_whence;    /* type of l_start */
  162.     off_t    l_start;    /* starting offset */
  163.     off_t    l_len;        /* len = 0 means until end of file */
  164.     pid_t    l_pid;        /* lock owner */
  165. };
  166.  
  167.  
  168. #ifndef _POSIX_SOURCE
  169. /* lock operations for flock(2) */
  170. #define    LOCK_SH        0x01        /* shared file lock */
  171. #define    LOCK_EX        0x02        /* exclusive file lock */
  172. #define    LOCK_NB        0x04        /* don't block when locking */
  173. #define    LOCK_UN        0x08        /* unlock file */
  174. #endif
  175.  
  176.  
  177. #ifndef KERNEL
  178. #include <sys/cdefs.h>
  179.  
  180. __BEGIN_DECLS
  181. int    open __P((const char *, int, ...));
  182. int    creat __P((const char *, mode_t));
  183. int    fcntl __P((int, int, ...));
  184. #ifndef _POSIX_SOURCE
  185. int    flock __P((int, int));
  186. #endif /* !_POSIX_SOURCE */
  187. __END_DECLS
  188. #endif
  189.  
  190. #endif /* !_FCNTL_H_ */
  191.